package com.sharker.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.sharker.R;
import com.sharker.models.CourseDetail;
import com.sharker.network.SharkerParams;

import org.xutils.common.Callback;
import org.xutils.x;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 项目名称：Sharker-master
 * 类描述：
 * 创建人：${丁江楠}
 * 创建时间：2017/4/13 11:21
 * 修改人：${丁江楠}
 * 修改时间：2017/4/13 11:21
 * 修改备注：
 */
public class CourseDetaildfragment extends Fragment {
    @BindView(R.id.course_detail_recycler)
    RecyclerView mRecyclerview;
    Unbinder unbinder;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.course_detail_item, null);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Bundle arguments = getArguments();
        String id = arguments.getString("id");
       // Toast.makeText(getActivity(),id,Toast.LENGTH_LONG).show();
        detailcourse(id);
    }
    private void detailcourse(String objected_id) {
        SharkerParams sharkerParams = new SharkerParams("detail_course");
        sharkerParams.addBodyParameter("object_id", objected_id);
        x.http().post(sharkerParams, new Callback.CommonCallback<CourseDetail>() {
            @Override
            public void onSuccess(CourseDetail result) {
                Toast.makeText(getActivity(),result.toString(),Toast.LENGTH_LONG).show();


            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {

            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
